package com.app.params;

import android.content.Context;
import android.view.View;

import com.app.params.bean.OnlickInterface;
import com.app.params.bean.ParamsBean;

import java.util.List;

import adapter.CommonAdapter;
import adapter.ViewHolder;

public class HistoryAdapter extends CommonAdapter {
    Onclick onclick;

    public HistoryAdapter(Context context, List<?> list) {
        super(context, list);
    }

    @Override
    public int onCreateViewLayoutID(int viewType) {
        return R.layout.item;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        ParamsBean paramsBean = (ParamsBean) list.get(position);
        holder.setTextView(R.id.parTime, paramsBean.getTime());
        holder.setTextView(R.id.parName, paramsBean.getParamsName());
        onclick = new Onclick(position, paramsBean);
        holder.get(R.id.itemLin).setOnClickListener(onclick);

    }

    OnlickInterface onlickInterface;

    public void setOnlickInterface(OnlickInterface onlickInterface) {
        this.onlickInterface = onlickInterface;
    }

    class Onclick implements View.OnClickListener {
        private int postition;
        private ParamsBean paramsBean;

        public Onclick(int postition, ParamsBean paramsBean) {
            this.postition = postition;
            this.paramsBean = paramsBean;
        }

        @Override
        public void onClick(View view) {
            if (onlickInterface != null) {
                onlickInterface.getParams(paramsBean);
            }
        }
    }
}
